package cn.bankAutoOffice.controller;

import cn.bankAutoOffice.bean.entity.Menu;
import cn.bankAutoOffice.common.utils.Result;
import cn.bankAutoOffice.service.MenuService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 金健伟
 * @DATE 2023/4/11 13:03
 * 功能说明：
 */

@RestController
public class MenuController {

    @Resource
    private MenuService menuService;

    @GetMapping("/getMenu")
    @RequiresPermissions("menu:view")
    public Result<List<Menu>> getMenus(){

        List<Menu> menus = menuService.getMenuByCurrentUser();

        if (menus == null){
            return Result.failure("用户未登录，请先登录！");
        }
        return Result.success(menus);
    }

}
